<?php
/**
 * Created by PhpStorm.
 * User: ly
 * Date: 2017\12\20 0020
 * Time: 13:42
 */

//use yii\grid\GridView;
//use yii\bootstrap\Html;
use kartik\grid\GridView;
use yii\helpers\Html;
use yii\widgets\LinkPager;
use backend\controllers\DtActionFilter;
/*基本信息 （混合类）*/
Yii::$app->session['tabID']=$tabID;
if($is_highlights!=1){
   // Yii::$app->session['is_highlights']='turnoff.png';
    $highlightsPic='turnoff.png';
}else{
//    Yii::$app->session['is_highlights']='turn.png';
    $highlightsPic='turn.png';
}
$this->registerCss('  
    .guarantee-table tfoot tr td{padding : 0 ;}
    #projectListBase{border-right: 1px solid #dbdbdb; border-left: 1px solid #dbdbdb; max-height : 525px;}
    #projectListBase table.guarantee-table{border: 1px solid #dbdbdb; border-left: none; border-right: none;}
    #projectListBase table.guarantee-table tr:hover{background : #e8f4fe;}
    #projectListBase table.guarantee-table tr:hover td input{background : #e8f4fe;}
');

echo GridView::widget([
    'dataProvider' => $projectListHH,
    'id'=>'projectListBase',
//    'pager' => [
////      'class' => GoPager::className(),
//        'firstPageLabel' => '首页',
//        'prevPageLabel' => '上一页',
//        'nextPageLabel' => '下一页',
//        'lastPageLabel' => '尾页',
//    ],
    'perfectScrollbar'=>true,
//    'showFooter' => true,
    'tableOptions' => [
        'class' => 'table  guarantee-table',
        'style' => ''//overflow: auto
    ],
    'columns' => [
        [
            'class' => 'yii\grid\CheckboxColumn',
            'header' => '序号',
            // 'header'=>'',
//            'footerOptions' => ['colspan' => 15],//data-toggle="modal" data-target="#AssetPackageEditing-adds"
//            'footer' => '',
        ],
        [
            'class' => 'yii\grid\SerialColumn',
//            'header'=>'序号',
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'borrower',//借款人名称
//            'contentOptions' => ['class'=>'txt-cut'],
            'format' => 'raw',
            'value' => function ($data) {
                $url="/project/getinfodata?package_id=".$data['package_id']."&project_id=".$data['id'];
                $borrower=Html::a(mb_substr($data['borrower'],0,8,'utf-8').'...',$url, ['target'=> '_blank','title'=>$data['borrower'],'class' => 'txt-cut']);
                if ($data['is_highlights']==1) {
                    return Html::img("/image/assetPackage/star.png", ['class' => 'pull-left']) . $borrower;
                }
                return $borrower;
//                return '$data[\'borrower\']$data[\'borrower\']$data[\'borrower\']$data[\'borrower\']$data[\'borrower\']$data[\'borrower\']';
            },
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'city',
            'format' => 'raw',
            'value' => function ($data) {
                return '<span style="width:100%;" class="txt-cut" title="'.$data['provinceName']['title'] . $data['cityName']['title'].'">'.$data['provinceName']['title'] . $data['cityName']['title'].'</span>';

            },
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'principal',//本金
            'format'=>['decimal', 2],
//            'footerOptions' => ['class' => 'hide']
        ],
        /*基础信息 开始*/
        [
            'attribute' => 'interest',//利息
            'format' => 'raw',
            'format'=>['decimal', 2],
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '本息合计',
            'format'=>['decimal', 2],
            'value' => function ($data) {
                return $data['principal'] + $data['interest'];
            },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute'=>'is_suit',
            'format' => 'raw',
            'value'=>function($data){
                $is_suit=Yii::$app->params['isSuit'];
                return '<span fd="is_suit" tb="p" style="width:100%;" class="txt-cut" title="'.$is_suit[$data['is_suit']]['name'].'">'.$is_suit[$data['is_suit']]['name'].'</span>';

            },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'management_status',//借款人状况management_status
            'format' => 'raw',
            'value' =>
                function ($data) {
                    $managementStatus = Yii::$app->params['managementStatus'];
                    return '<span fd="management_status" tb="p" style="width:100%;" class="txt-cut" title="'.$managementStatus[$data['management_status']].'">'.$managementStatus[$data['management_status']].'</span>';
                },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'enterprise',//企业enterprise
            // 'contentOptions' => ['class'=>'txt-cut'],
            'format' => 'raw',
            'value' =>
                function ($data) {
                    $projectEnterprise = Yii::$app->params['project_enterprise'];
                    
                    return '<span  fd="enterprise" tb="p" style="width:100%" class="txt-cut" title="'.$projectEnterprise[$data['enterprise']].'">'.$projectEnterprise[$data['enterprise']].'</span>';
                    // return $projectEnterprise[5];
                },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'industry',//行业industry
            'format' => 'raw',
            'value'=>function($data){
                $industrys=Yii::$app->params['industrys'];
                if(empty($data['industry'])){
                    return '<span fd="industry" tb="p">--</span>';
                }else{
                    $industryIDs=explode(',',$data['industry']);
                    $str='';
                    foreach($industryIDs as $val){
                        if(!empty($str)){
                            $str.=',';
                        }
                        $str.=$industrys[$val]['name'];
                    }
                    // return $str;
                   return '<span fd="industry" tb="p" style="width:100%;" class="txt-cut" title="'.$str.'">'.$str.'</span>';
                }
            },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'guarantor',//保证人/抵押人
            // 'contentOptions' => ['class'=>'txt-cut'],
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="guarantor" tb="p" style="width:100%;" class="txt-cut" title="'.$data['guarantor'].'">'.mb_substr($data['guarantor'],0,10,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'warranty',//担保方式
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="warranty" tb="p" style="width:100%;" class="txt-cut" title="'.$data['warranty'].'">'.mb_substr($data['warranty'],0,10,'utf-8').'</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
        ],

        [
            'attribute' => 'guarantor_status',//保证人状况guarantor_status
            'format' => 'raw',
            'value' =>
               function ($data) {
                    return '<span fd="guarantor_status" tb="p" style="width:100%;" class="txt-cut" title="'.$data['guarantor_status'].'">'.$data['guarantor_status'].'</span>';

               },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'mortgage_type',//抵押物类型
            'format' => 'raw',
            'value' =>
                function ($model) {
                    $mortgageType = Yii::$app->params['mortgageTypes3'];
                    $str='';
                    $mortgage_type=explode(',',$model->mortgage_type);
                    foreach($mortgage_type as $val){
                        if($val>0){
                            if($str) $str.=',';
                            $str.=$mortgageType[$val]['name'];
                        }
                    }
                    return '<span fd="mortgage_type" tb="p" style="width:100%;" class="txt-cut" title="'.$str.'">'.$str.'</span>';
                },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => 'highlights',//亮点明细
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="highlights" tb="p" style="width:100%;" class="txt-cut" title="'.$data['highlights'].'">'.mb_substr($data['highlights'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 1,
            'contentOptions' => ['class'=>''],
//            'footerOptions' => ['class' => 'hide']
        ],
        /*基础信息 结束*/
        /*司法进展 开始*/
        [
            'attribute' => '判决',
            // 'contentOptions' => ['class'=>'hideTH'],
//            'value' => 'lawsuit.judgement',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="judgement" tb="pl" style="width:100%;" class="txt-cut" title="'.$data['lawsuit']['judgement'].'">'.mb_substr($data['lawsuit']['judgement'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 2,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '执行',
//            'value' => 'lawsuit.execution',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="execution" tb="pl" style="width:100%;" class="txt-cut" title="'.$data['lawsuit']['execution'].'">'.mb_substr($data['lawsuit']['execution'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 2,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '法院',
//            'value' => 'lawsuit.court',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="court" tb="pl" style="width:100%;" class="txt-cut" title="'.$data['lawsuit']['court'].'">'.mb_substr($data['lawsuit']['court'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 2,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '列失信',
//            'value' =>'lawsuit.block',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="block" tb="pl" style="width:100%;" class="txt-cut" title="'.$data['lawsuit']['block'].'">'.mb_substr($data['lawsuit']['block'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 2,
//            'footerOptions' => ['class' => 'hide']
        ],
        /*司法进展 结束*/
        /*价值评估 开始*/
        [

            'attribute' => '参考资产市场价值',
//            'value' => 'evaluation.reference',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="reference" tb="peve" style="width:100%;" class="txt-cut" title="'.$data['evaluation']['reference'].'">'.mb_substr($data['evaluation']['reference'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 3,
//            'footerOptions' => ['class' => 'hide']
        ],
        [

            'attribute' => '保守回收预估值',
//            'value' => 'evaluation.conservation',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="conservation" tb="peve" style="width:100px;" class="txt-cut" title="'.$data['evaluation']['conservation'].'">'.mb_substr($data['evaluation']['conservation'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 3,
//            'footerOptions' => ['class' => 'hide']
        ],
        [

            'attribute' => '激进回收预估值',
//            'value' => 'evaluation.radical',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="radical" tb="peve" style="width:100%;" class="txt-cut" title="'.$data['evaluation']['radical'].'">'.mb_substr($data['evaluation']['radical'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 3,
//            'footerOptions' => ['class' => 'hide']
        ],
        [

            'attribute' => '回收预评估价值说明',
//            'value' => 'evaluation.recall',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="recall" tb="peve" style="width:100%;" class="txt-cut" title="'.$data['evaluation']['recall'].'">'.mb_substr($data['evaluation']['recall'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 3,
//            'footerOptions' => ['class' => 'hide']
        ],
        /*价值评估 结束*/
        /*补充说明 开始*/
        [
            'attribute' => '法律依据',
//            'value' => 'note.legal',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="legal" tb="pn" style="width:100%;" class="txt-cut" title="'.$data['note']['legal'].'">'.mb_substr($data['note']['legal'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 4,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '处置方案',
//            'value' => 'note.sell_plan',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="sell_plan" tb="pn" style="width:100px;" class="txt-cut" title="'.$data['note']['sell_plan'].'">'.mb_substr($data['note']['sell_plan'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 4,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '风险点',
//            'contentOptions' => ['class'=>'txt-cut'],
//            'value' => 'note.risk_point',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="risk_point" tb="pn" style="width:100%;" class="txt-cut" title="'.$data['note']['risk_point'].'">'.mb_substr($data['note']['risk_point'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 4,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '承债人现状',
//            'contentOptions' => ['class'=>'txt-cut'],
//            'value' => 'note.current_state',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="current_state" tb="pn" style="width:100%;" class="txt-cut" title="'.$data['note']['current_state'].'">'.mb_substr($data['note']['current_state'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 4,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '其他问题',
//            'contentOptions' => ['class'=>'txt-cut'],
//            'value' => 'note.other_problem',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="other_problem" tb="pn" style="width:100%;" class="txt-cut" title="'.$data['note']['other_problem'].'">'.mb_substr($data['note']['other_problem'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 4,
//            'footerOptions' => ['class' => 'hide']
        ],
        [
            'attribute' => '需再补充',
//            'contentOptions' => ['class'=>'txt-cut'],
//            'value' => 'note.more_problem',
            'format' => 'raw',
            'value'=>function($data){
                return '<span fd="more_problem" tb="pn" style="width:100%;" class="txt-cut" title="'.$data['note']['more_problem'].'">'.mb_substr($data['note']['more_problem'],0,20,'utf-8').'...</span>';
            },
            'visible' => intval(Yii::$app->session['tabID']) == 4,
//            'footerOptions' => ['class' => 'hide']
        ],
    ],
    'layout' => "{items}",
    'options' => ['class' => 'table  guarantee-table']
]);
unset(Yii::$app->session['tabID']);
//unset(Yii::$app->session['is_highlight']);
?>
<ul class="table-foot-ul">
    <li class="pull-left">
        <input type="checkbox" id="check1" class="select-on-check-all pull-left" style="width: 20px; margin-top: 2px;" name="selection_all_hh" value="1">
    </li>
    <li class="pull-left"><label for="check1">全选</label></li>
    <?php
    if(DtActionFilter::checkPackage('package_edit', Yii::$app->session->get('packageid')))
       echo '
        <li class="pull-left asset-package-editing-adds" typeid="1">新增</li>
        <li class="pull-left del-projects">删除</li>
        <li class="pull-left asset-package-editing-down" typeid="1">下载</li>
        <li class="pull-left asset-package-editing-move"  typeid="2">移动到抵押类列表</li>
       ';
    ?>
    <li class="pull-left asset-package-editing-calculate" typeid="1">计算求和</li>
    <li class="pull-left asset-package-editing-filtrate" typeid="1">高级筛选</li>
    <li class="pull-left table-foot-turn" onclick="onlyShowLight(this)" typeid="0">
        <img src="/image/assetPackage/<?php echo $highlightsPic;?>" class="pull-left" style="margin-top: 17px; margin-right: 5px;">
        <span class="pull-left">只显示亮点项目</span>
    </li>
</ul>
<div class="pagingBox">
    <?php
    echo LinkPager::widget([
        'pagination' => $projectListHH->pagination,
        'firstPageLabel' => '首页',
        'lastPageLabel' => '尾页',
        'nextPageLabel' => '下一页',
        'prevPageLabel' => '上一页',

    ]);
    ?>
    <div style="float: right;margin: 20px;">
        <!--                <form action="--><?php //echo $_SERVER['REQUEST_URI'] ;?><!--"  method="get" class="pageTotal" id="pageSizeForm">-->
        <span class="lf">每页显示</span>
        <select class="pane" name="per-page-hh" id="per-page-hh">
            <option value="10" <?php echo $projectListHH->pagination->pagesize==10?'selected':'';?>>10</option>
            <option value="20" <?php echo $projectListHH->pagination->pagesize==20?'selected':'';?>>20</option>
            <option value="30" <?php echo $projectListHH->pagination->pagesize==30?'selected':'';?>>30</option>
            <option value="40" <?php echo $projectListHH->pagination->pagesize==40?'selected':'';?>>40</option>
            <option value="50" <?php echo $projectListHH->pagination->pagesize==50?'selected':'';?>>50</option>
        </select>条
        <!--                </form>-->
        <span class="totalSize">共<?php echo $projectListHH->pagination->totalCount;?></span>条记录
    </div>
</div>



